import React, { PureComponent } from 'react'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import App from './App'
import Common from './common'
import Login from './page/Login'
import Admin from './admin'
import Home from './page/home'
import Buttons from './page/ui/buttons'
import NoMatch from './page/nomath'
import Modals from './page/ui/modal'
import Loadings from './page/ui/spin'
import Notice from './page/ui/Notice'
import Tabs from './page/ui/Tabs'
import Gallery from './page/ui/Gallery'
import Carousel from './page/ui/Carousel'
import FormLogin from './page/form/login'
import FormRegister from './page/form/Register'
import BasicTable from './page/table/BasicTable'
import HighTable from './page/table/HighTable'
import Rich from './page/Rich/index'
import City from './page/City/index'
import Order from './page/Order/index'
import OrderDetail from './page/Order/detail'
import User from './page/User/index'
import Bar from './page/echarts/Bar/index'
import Pie from './page/echarts/pie'
import Line from './page/echarts/line'
import BikeMap from './page/map/BikeMap'
import Permission from './page/Permission/index'

export default class IRouter extends PureComponent {
  render () {
    return (
      <BrowserRouter>
        <App>
          <Switch>
            <Route path="/login" component={Login}></Route>
            <Route path="/common" render={() =>
              <Common>
                <Route path="/common/order/detail/:orderId" component={OrderDetail} />
              </Common>
            }
            />
            <Route path="/" render={() =>
              <Admin>
                <Switch>
                  <Route path='/home' component={Home} />
                  <Route path="/ui/buttons" component={Buttons} />
                  <Route path="/ui/modals" component={Modals} />
                  <Route path="/ui/loadings" component={Loadings} />
                  <Route path="/ui/notification" component={Notice} />
                  <Route path="/ui/tabs" component={Tabs} />
                  <Route path="/ui/gallery" component={Gallery} />
                  <Route path="/ui/carousel" component={Carousel} />
                  <Route path="/form/login" component={FormLogin} />
                  <Route path="/form/reg" component={FormRegister} />
                  <Route path="/table/basic" component={BasicTable} />
                  <Route path="/table/high" component={HighTable} />
                  <Route path='/rich' component={Rich} />
                  <Route path="/city" component={City} />
                  <Route path="/order" component={Order} />
                  <Route path='/user' component={User} />
                  <Route path="/charts/bar" component={Bar} />
                  <Route path="/charts/pie" component={Pie} />
                  <Route path="/charts/line" component={Line} />
                  <Route path='/bikeMap' component={BikeMap} />
                  <Route path="/permission" component={Permission} />
                  <Route component={NoMatch} />
                </Switch>
              </Admin>
            } />
          </Switch>
        </App>
      </BrowserRouter>
    )
  }
}
